<?php

class Game {
    public $player = array();
    public $bot = array();

    public function __construct() {
        echo 'Game Start <br>';
    }

    public function import($object){
        echo '<pre>';

        $object = (object) $object;

        $type = get_class($object);
        $playerOrBot = strtolower($type);

        /** @var stats to build the object */
        $name = $object->getName();
        $hp = $object->getHp();
        $dmg = $object->getDmg();

        $this->{$playerOrBot}[$name] = new $type($this, $name);
        $this->{$playerOrBot}[$name]->setHp($hp);
        $this->{$playerOrBot}[$name]->setDmg($dmg);
    }

    public function create($type, $name) {

        $type = strtolower($type);
//        $name = strtolower($name);

        if (isset($this->player[$name])) {
            echo 'This player $name is taken';
            return false;
        }

        switch ($type)
        {
            case 'player':
                $this->player[$name] = new Player($this, $name);
                break;
            case 'bot':
                $this->bot[$name] = new Bot($this, $name);
                break;
            default:
                echo 'error character <br>';
        }
    }
}